﻿<Window 
     x:Class="UsingNonMVVMElements.MainWindowBindingReadOnlyPropertiesWithDynamicParameter"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
     Height="481" Width="688"
     xmlns:vm="clr-namespace:UsingNonMVVMElements.ViewModel"
     xmlns:converter="clr-namespace:UsingNonMVVMElements.Converter"
     xmlns:core="clr-namespace:UsingNonMVVMElements.Core"   
     xmlns:command="clr-namespace:UsingNonMVVMElements.Command"
     Title="MVVM Light Application">
    <Window.DataContext>
        <vm:MainWindowViewModel />
    </Window.DataContext>
    <Window.Resources>        
        <command:GoBackWithWebBrowserDynamicParameterCommand 
            x:Key="goBackCommand" />
        <converter:UriConverter x:Key="uriConverter" />
    </Window.Resources>
    <Grid x:Name="LayoutRoot">
        <TextBox Height="27" HorizontalAlignment="Left" Margin="2,1,0,0" 
                 Name="textBoxUrl" VerticalAlignment="Top" Width="611"
                 Text="{Binding UserSuggestedSourcePage}" />
        <Button Content="Go" Height="27" HorizontalAlignment="Left" 
                Margin="615,1,0,0" Name="btnGo" VerticalAlignment="Top" 
                Width="39" IsDefault="True"
                Command="{Binding NavigateUrlCommand}" />
        <WebBrowser x:Name="webBrowser" Margin="0,59,0,0" />
        <core:BindingReflector            
            x:Name="sourceReflector">
            <core:BindingReflector.Target>
                <Binding ElementName="webBrowser" 
                         Path="Source" Mode="OneWayToSource" />
            </core:BindingReflector.Target>
            <core:BindingReflector.Source>
                <Binding Path="SourcePage" Mode="OneWay" 
                         Converter="{StaticResource uriConverter}"/>
            </core:BindingReflector.Source>
        </core:BindingReflector>
        <Button Content="Back" Height="26" HorizontalAlignment="Left" 
                Command="{Binding Source={StaticResource goBackCommand}}"                 
                CommandParameter="{Binding ElementName=webBrowser}"
                Margin="2,30,0,0" Name="btnBack" VerticalAlignment="Top" 
                Width="67" />
    </Grid>
</Window>

